<?php

/**
 * App model
 *
 * @package       AgencyCMS
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/**
 * AppModel
 */
class AppModel extends Model {

    /**
     * Translate all validation error messages by default
     * @param string $field
     * @param mixed $value
     * @return string
     */
    function invalidate($field, $value = true)
    {
        return parent::invalidate($field, __($value, true));
    }

    /**
     * Validation rule to compare 2 fields
     * @param array $field
     * @param string $compareField
     * @return bool
     */
    function identicalFieldValues($field = array(), $compareField = null) 
    {
        foreach($field as $key => $value) {
            $v1 = $value;
            $v2 = $this->data[$this->name][$compareField];                 
            if ($v1 !== $v2) {
                return false;
            } else {
                continue;
            }
        }
        return true;
    }

}